import config from '../../../mp.config.js'
import './device.css';
// import tpl from './device.html';

export class Device {
	constructor() {
		this.appContainer = null;

    	//客户端平台: app App应用,devtool 开发者工具
		if(config.platform === 'app') {
			this.root = document.querySelector('#app');
		} else {
			this.root = document.querySelector('#abb');
		}

		this.init();
	}

	init() {
		this.root.innerHTML = `
            <div id="root" class="mp-box">
                <div class="mp-body-box">
                    
                </div>
            </div>
        `;
		this.appContainer = this.root.querySelector('.mp-body-box');
        
        //设置状态栏颜色模式
		// this.updateDeviceBarColor('white');
	}

	//设置状态栏颜色模式
	updateDeviceBarColor(color) {
		const statusBar = this.root.querySelector('.mp-bar-box');

		if (color === 'black') {
            statusBar.classList.add('mp-bar-bg-black');
			statusBar.classList.remove('mp-bar-bg-white');
		}

		if (color === 'white') {
            statusBar.classList.add('mp-bar-bg-white');
			statusBar.classList.remove('mp-bar-bg-black');
		}
	}

    //打开微信应用
	open(app) {
		//设备信息给application.js
		app.parent = this;
		this.appContainer.appendChild(app.el);
	}
}

